<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="_session_check.jsp" %>
<%@ page import="com.shopping.modean.*"%>
<%@ page import="com.shopping.service.*"%>
<%@ page import="com.shopping.util.*"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%
    //获取pid的分类
    request.setCharacterEncoding("UTF-8");
    String pidStr = request.getParameter("pid");  
    int pid = pidStr == null ? 0 : Integer.parseInt(pidStr);  
	CategoryService categoyService = new CategoryService();
	List<Category> categorys = categoyService.list(pid);
%>

<!DOCTYPE html>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>分类列表</title>
</head>

<body>

  <table border="1" align="center">
  	<tr>
  		<td>ID</td>
  		<td>分类名称</td>
  		<td>分类描述</td>
  		<td>PID</td>
  		<td>级别</td>
  		<td>操作</td>
  	</tr>
    
    <%
    	for(Category c : categorys) {
  
    %>
    <tr>
  		<td><%=c.getId() %></td>
  		<td><%=c.getName() %></td>
  		<td><%=c.getDescr() %></td>
  		<td><%=c.getPid() %></td>
  		<td><%=c.getGrade() %></td>
  		<td>
  		  <a href="category_update.jsp?id=<%=c.getId() %>">修改</a>
  		  <span>|</span>
  		  <a href="category_delete.jsp?action=categoryDeleteSub&id=<%=c.getId() %>&pid=<%=c.getPid() %>">删除</a>	
  		</td>
  	</tr>
     <% } %>
    <tr>
    	<td colspan="6" align="center">
    	  <a href="category_list.jsp">返回上一个页面</a>
    	</td>
    </tr>
  </table>
  

</body>
</html>